package com.iemes.controller.finance;

import java.util.List;
import java.util.Map;

import javax.inject.Inject;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.iemes.annotation.SystemLog;
import com.iemes.controller.index.BaseController;
import com.iemes.entity.MainMouldFileFormMap;
import com.iemes.mapper.mould.MainMouldFileMapper;
import com.iemes.plugin.PageView;
import com.iemes.util.Common;

@RequestMapping("/finance")
@Controller
public class MainMouldFileController extends BaseController {

	@Inject
	private MainMouldFileMapper mainMouldFileMapper;
	
	@RequestMapping("mainmouldfile")
	public String loss(Model model){
		model.addAttribute("res", findByRes());
		return Common.BACKGROUND_PATH + "/finance/receivablesmanagement/mainmouldfile_list";
	}
	
	@ResponseBody
	@RequestMapping("mainmouldfile_findByPage")
	public PageView findByPage(String pageNow, String pageSize) throws Exception 
	{
		MainMouldFileFormMap mainMouldFileFormMap=getFormMap(MainMouldFileFormMap.class);
		List<Map<String,Object>> mainMouldFileFormMaps=mainMouldFileMapper.getMainMouldFileFormMapByConditon(mainMouldFileFormMap);
		LuogicPaging(pageNow, pageSize, mainMouldFileFormMaps);
		return pageView;
	}
	
	@RequestMapping("mainmouldfile_edit")
	public String editUI(Model model) throws Exception 
	{
		String id = getPara("id");
		MainMouldFileFormMap mainMouldFileFormMap=mainMouldFileMapper.getMainMouldFileFormMapById(Integer.parseInt(id));
		model.addAttribute("mainMouldFileFormMap", mainMouldFileFormMap);
		return Common.BACKGROUND_PATH + "/finance/receivablesmanagement/mainmouldfile_edit";
	}
	
	@ResponseBody
	@RequestMapping(value="mainmouldfile_editEntity")
	@SystemLog(module="模具产权列表",methods="模具产权列表-修改")//凡需要处理业务逻辑的.都需要记录操作日志
	public String editEntity() throws Exception {
		MainMouldFileFormMap mainMouldFileFormMap=getFormMap(MainMouldFileFormMap.class);
		mainMouldFileMapper.editEntity(mainMouldFileFormMap);
		return "success";
	}
}
